home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The CICA Windows Explosion!
/
The CICA Windows Explosion! - Disc 2.iso
/
programr
/
t-bcinfo.zip
/
TI717.ZIP
/
TI717.ASC
Wrap
Text File
|
1992-02-25
|
2KB
|
67 lines
PRODUCT : Borland C++ NUMBER : 717
VERSION : 2.0
OS : DOS
DATE : February 25, 1992 PAGE : 1/1
TITLE : Getting Amount of Available Memory on the Far Heap
/************************************************************************
Purpose:
This function will determine how much memory is available
on the far heap.
Usage:
To use this function you must put the statement:
extern unsigned long heapsize(void);
within the scope of the calling function.
Method:
The memory available on the far heap is computed by
determining the sum of the freed blocks of memory and
adding that amount to the value returned by coreleft().
***********************************************************************/
#include <alloc.h>
#include <stdio.h>
unsigned long heapsize(void)
{
unsigned long i = 0; /* Return variable */
struct farheapinfo hi; /* Value returned from farheapwalk */
hi.ptr = NULL; /* Set the beginning of farheapwalk*/
if( farheapcheck() <= 0 ) /* Check for corrupted heap */
return (-1L);
while( farheapwalk(&hi) == _HEAPOK ) /* Walk the heap and sum
size of free blocks */
if( hi.in_use == 0 )
i += hi.size;
i += farcoreleft(); /* Check for amount of free memory from
the highest allocated block to the end
of DOS */
return i;
}